<!--图书分类-->
<template>
  <div class="category">
    <h3>图书分类</h3>
    <div
      class="category_book"
      v-for="category in categoryies"
      :key="category.id"
    >
      <h4>{{ category.name }}</h4>
      <router-link :to="{name:'category',params:{id:child.id}}" v-for="child in category.children" :key="child.id"
        >{{ child.name }}&nbsp;&nbsp;</router-link
      >
    </div>
  </div>
</template>

<script>
export default {
  name: "HomeCategory",
  data() {
    return {
      categoryies: [],
    };
  },
  created() {
    this.axios
      .get("/category")
      .then((res) => {
        this.categoryies = res.data;
      })
      .catch((error) => console.log(error));
  },
};
</script>

<style>
.category {
  flex: 2;
  text-align: center;
  border: 3px solid gainsboro;
  height: 100%;
  padding: 0 10px;
  padding-bottom: 10px;
  margin: 0 10px;
}

.category h3 {
  font-weight: 700;
  font-size: 20px;
  padding: 10px 0;
}

.category_book h4 {
  font-weight: 700;
  padding: 20px 0;
}
.category a {
  margin: 8px 0;
}
</style>